/*
package com.sailfish.springbootdemo.controller;

import com.sailfish.springbootdemo.service.TestService;
import com.sailfish.springbootdemo.utils.Md5Util;
import com.sailfish.springbootdemo.utils.RequestParamUtil;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import java.util.Map;
import java.util.Properties;

@RestController
@RequestMapping("/test")
@CrossOrigin
public class TestController {

    @Autowired
    private TestService testService;

    @PostMapping("/test")
    public String test(String param){
        Map<String, Object> map = RequestParamUtil.getJSONObject(param);
        String str="";
        if(map.get("result").equals(true)){
            if(RequestParamUtil.paramIsExistNode((JSONObject)map.get("data"),"name")){
                if(RequestParamUtil.paramIsEmpty((JSONObject)map.get("data"),"name")){
                    System.out.println("name="+map.get("name"));
                    str = ((JSONObject) map.get("data")).get("name").toString();
                }else{
                    System.out.println("name参数不能为空");
                    str = "name参数不能为空";
                }
            }else{
                System.out.println("name参数未传入");
                str = "name参数未传入";
            }

        }else{
            str = map.get("msg").toString();
        }
        return str;
    }


    @PostMapping("/testMd5")
    public String testMd5(String pwd){
        try{
            return Md5Util.encryptPwd(pwd);
        }catch (Exception e){
            return e.getMessage();
        }
    }

    @PostMapping("/testToken")
    public String testToken(){
        return "success";
    }

    @GetMapping("/sendEmail")
    public void sendEmail(){

        //发送邮箱验证
        try {
            Properties prop = new Properties();
            prop.setProperty("mail.transport.protocol", "smtp");
            prop.setProperty("mail.smtp.host", "smtp.qq.com");
            prop.setProperty("mail.smtp.auth", "true");
            prop.put("mail.smtp.port","25");
            prop.setProperty("mail.debug", "true");
            Authenticator authenticator = new PopAuthenticator("694854706@qq.com", "zvnjdpjcvepabajc");
            //创建会话
            Session session = Session.getInstance(prop,authenticator);
            //填写信封写信
            Message msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress("694854706@qq.com"));
            msg.setRecipient(Message.RecipientType.TO, new InternetAddress("charlihan@sailfish.tech"));
            msg.setSubject("拜访邮件提醒!");
            msg.setText("你需要拜访YaphetS了，哈哈哈哈哈!(此邮件来自测试，完全可以忽略!!)");
            //验证用户名密码发送邮件
            Transport transport = session.getTransport();
            transport.send(msg);
        }catch (Exception e){
            System.out.println(e);
        }
    }

    */
/**
 * 测试 数据源1 的事务
 * <p>
 * 测试 数据源2 的事务
 *//*

    @PostMapping("testTransaction1")
    public void testTransaction1(){
        testService.TestInsertUser1();
    }

    */
/**
 * 测试 数据源2 的事务
 *//*

    @PostMapping("testTransaction2")
    public void testTransaction2(){
        testService.TestInsertUser2();
    }
}
*/
